﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace web4
{
    public partial class _2016020719_1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            TextBox1.Focus();
            Table1.Width = 400;
            Table1.Caption = "动态生成表格";
            Table1.GridLines = GridLines.Both;
            Table1.HorizontalAlign = HorizontalAlign.Center;

            Table1.CellPadding = 0;
            Table1.CellSpacing = 0;
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (TextBox1.Text == "" || TextBox2.Text == "")
            {
                Label1.Text = "必须输入行、列数！";
                Table1.Caption = "必须输入行、列数";
                return;
            
            }
            int iRows = int.Parse(TextBox1.Text);
            int iCells = int.Parse(TextBox2.Text);
            for (int i = 0; i < iRows; i++)
            {
                TableRow myRow = new TableRow();
                for (int j = 0; j < iCells; j++)
                {
                    TableCell myCell = new TableCell();
                    myCell.Text = i.ToString() + "," + j.ToString();
                    myRow.Cells.Add(myCell);
                }
                Table1.Rows.Add(myRow);
            }
        }
    }
}